package com.business.lgh.naocs.naming.consistency.ephemeral.distro;

import com.business.lgh.naocs.naming.consistency.Record;
import com.business.lgh.naocs.naming.core.pojo.Instances;
import com.business.lgh.naocs.naming.misc.Datum;
import lombok.Data;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author lgh
 * @version V1.0
 * @Package com.business.lgh.naocs.naming.consistency.ephemeral.distro
 * @date 2020/6/24 6:38 下午
 */
@Data
@Component
public class DataStore implements Serializable {

    private Map<String, Datum> datasource = new ConcurrentHashMap<>();


    public Datum get(String key) {
        return datasource.get(key);
    }

    public void put(String key, Datum value) {
        datasource.put(key, value);
    }

    public void setDatasource(Map<String, Datum> stringDatumMap) {
        stringDatumMap.forEach((k,v)->{
            datasource.put(k,v);
        });

    }
}
